<template>
	<view :style="theme">
		<view class="cardCont bt2Cont">
			<view v-for="(item, index) in list" :key="index" class="box_item mb2" @click="jumpBtn(item)">
				<image :src="imgHost + '/ic_xianshi@2x.png'" class="ms"></image>
				<image :src="item.businessImg?item.businessImg:imgHost+'/default_list.jpg'" class="left"></image>
				<view class="right">
					<view class="f30 c2 limit-1-line">
						{{item.businessName || ''}}
					</view>
					<view class="f22 c9 mt10">
						{{item.businessInfo}}
					</view>
					<view class="zsd flex mt10 flex_between">
						<view class="f22">
							<text>¥</text>
							<text>{{item.discountPrice}}</text>
							<text>¥{{item.businessOriginPrice}}</text>
						</view>
						<view v-if="item.status != '0'" class="payBtn">
							抢购
						</view>
						<view v-if="item.status == '0'" class="payBtn hui">
							即将开抢
						</view>
					</view>
				</view>
			</view>
		</view>
		<u-loadmore v-if="end && list.length >= 10" :status="status" line />
		<view v-if="list.length === 0" class="no-order">
			<image :src="imgHost+'/default_nodata.png'"></image>
			<view>暂无数据</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				status: 'nomore',
				page: 1,
				rows: 10,
				noClick: true,
				end: false,
				list: [],
				firstQueryTime: '',
			}
		},
		onLoad(ops) {
			this.firstQueryTime = this.$app.firstQueryTime()
			this.getList()
		},
		methods: {
			jump(url, params, a) {
				this.$app.jump(url, params, a);
			},
			jump2(url, params, a) {
				this.$app.jump2(url, params, a);
			},
			jumpBtn(e) {
				if(e.businessType == '04') {
					this.jump('/pages/setmeal/detail?id=',e.businessId)
				} else if(e.businessType == '07') {
					this.jump('/pages/curriculum/detail?id=', e.businessId)
				} else if(e.businessType == '19') {
					this.jump('/subPackages/special/details?id=',e.businessId)
				}
			},
			getList() {
				this.$app.ajax({
					api: this.$api.secKillList(),
					data: {
						pagination: {
							page: this.page,
							firstQueryTime: this.firstQueryTime,
							rows: 10
						},
						param: {
							type: '1'
						}
					}
				}).then((res) => {
					if (res.errorCode === '000000') {
						if (!res.recordList || res.recordList.length < this.rows) {
							this.end = true
						}
						if (res.recordList) {
							this.list = this.list.concat(res.recordList)
						}
					}
				}).catch(() => {})
			},
			reachBottom() {
				if (!this.end) {
					this.page += 1;
					this.getList();
				}
			},
			// 触底加载更多数据
			onReachBottom(e) {
				this.reachBottom()
			}
		},

	}
</script>
<style lang="scss" scoped>
	.zsd {
		color: #FE2C2E;
	}
	.bt2Cont {
		display: flex;
		flex-wrap: wrap;
		padding-top: 30rpx;
	
		.box_item {
			box-sizing: border-box;
			width: 334rpx;
			padding: 16rpx;
			background: linear-gradient(360deg, #FFFFFF 0%, #FFFCFC 40%, #FFF2D7 100%);
			border-radius: 8rpx;
			position: relative;
			margin-right: 22rpx;
	
			&:nth-child(2n) {
				margin-right: 0;
			}
	
			.ms {
				position: absolute;
				left: 8rpx;
				z-index: 2;
				width: 76rpx;
				height: 46rpx;
				top: 8rpx;
			}
	
			.left {
				width: 260rpx;
				height: 148rpx;
				border-radius: 8rpx;
				margin-right: 16rpx;
				flex: none;
			}
	
			.right {
				flex: 1;
	
				.zsd {
					height: 52rpx;
	
					.f22 {
						text {
							display: inline-block;
	
							&:nth-of-type(2) {
								font-size: 32rpx;
								font-weight: bolder;
							}
	
							&:nth-of-type(3) {
								margin-left: 8rpx;
								text-decoration: line-through;
								color: #999999;
							}
						}
					}
				}
	
				.payBtn {
					width: 84rpx;
					height: 52rpx;
					text-align: center;
					line-height: 52rpx;
					background: linear-gradient(270deg, #FE2C2E 0%, #FF6A1F 100%);
					box-shadow: 0rpx 4rpx 8rpx 0rpx rgba(254, 44, 46, 0.24);
					border-radius: 26rpx;
					font-size: 26rpx;
					font-family: PingFangSC, PingFang SC;
					font-weight: Medium;
					color: #FFFFFF;
					&.hui {
						width: 136rpx;
						background: linear-gradient(270deg, #FE2C2E 0%, #FF7C30 100%);
						box-shadow: 0rpx 4rpx 8rpx 0rpx rgba(254, 44, 46, 0.24);
						opacity: 0.6;
					}
				}
			}
		}
	}
</style>